import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  String val;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Container(
          alignment: Alignment.center,
          constraints: BoxConstraints(
              maxHeight: 38,
              maxWidth: 230
          ),
          foregroundDecoration: BoxDecoration(
            border: Border.all(color: Colors.black26,width: 1),
            borderRadius: BorderRadius.all(Radius.circular(20))
          ),
          child: TextField(
              onSubmitted: (text){
                print(text);
              },
              controller: TextEditingController(
                  text: val
              ),
              maxLines: 1,
              showCursor: true,
              decoration: InputDecoration(
                  border: InputBorder.none,
                  hintText: '请输入搜索的内容',
                  hintStyle: TextStyle(
                    color: Colors.black45,
                    wordSpacing: 2
                  ),
                  prefixIcon: Icon(Icons.search,color: Colors.white,),
                  /*suffixIcon: IconButton(
                      icon: Icon(Icons.cancel,color: Colors.white,),
                      onPressed: () {
                        this.setState((){
                          this.val = "";
                        });
                      })*/
              ),
            ),
          ),
        actions: <Widget>[
          Icon(Icons.home),
          Icon(Icons.schedule),
          Icon(Icons.message)
        ],
      ),
    );
  }
}
